<template>
  <div>
    <el-container class="main-el-contarner">
      <el-main>
        <div class="kanbao-bigbox">
          <div class="righttop-search-box">
            <el-form
              :inline="true"
              :model="param"
              label-width="100px"
              @submit.native.prevent
            >
              <el-form-item label="" label-width="10px">
                <el-input
                  placeholder="请输入联动动作关键字检索"
                  clearable
                  v-model="param.name"
                  size="small"
                  style="width: 350px"
                  @keyup.enter.native="onSearch"
                >
                  <i slot="prefix" class="el-input__icon el-icon-search"></i>
                </el-input>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" size="small" @click="onSearch">查找</el-button>
              </el-form-item>

              <!-- <el-form-item style="float: right">
                <el-button size="mini" type="primary" plain @click="handleAdd"><i class="el-icon-download"></i>
                  导出数据</el-button>
              </el-form-item> -->
              <el-form-item style="float: right">
                <el-button
                  type="text"
                  v-if="selectionChangeData == ''"
                  disabled
                  style="color: #cdc5bf"
                  ><i class="el-icon-delete"></i>删除数据</el-button
                >
                <el-button type="text" v-else style="color: #ff0000" @click="delClick"
                  ><i class="el-icon-delete"></i> 删除数据</el-button
                >
              </el-form-item>
              <el-form-item style="float: right">
                <el-button type="text" style="color: #18bc9c" @click="AddData"
                  ><i class="el-icon-plus"></i> 新增动作</el-button
                >
              </el-form-item>
              <el-form-item style="float: right" v-if="statusData == '1'">
                <el-button
                  size="mini"
                  type="danger"
                  @click="forbiddenClick"
                  style="color: #ffffff"
                  ><i class="el-icon-video-pause"></i> 禁用</el-button
                >
              </el-form-item>
              <el-form-item style="float: right" v-if="statusData == '0'">
                <el-button
                  size="mini"
                  type="primary"
                  @click="forbiddenClick"
                  style="color: #ffffff"
                  ><i class="el-icon-video-play"></i> 启用</el-button
                >
              </el-form-item>
              <el-form-item style="float: right" v-if="statusData == ''">
                <el-button disabled size="mini" type="danger" style="color: #ffffff"
                  ><i class="el-icon-video-pause"></i> 禁用</el-button
                >
              </el-form-item>
              <el-form-item style="float: right" v-if="statusData == ''">
                <el-button disabled size="mini" type="primary" style="color: #ffffff"
                  ><i class="el-icon-video-play"></i> 启用</el-button
                >
              </el-form-item>
            </el-form>
          </div>
          <div
            class="container-box"
            v-loading="loading"
            element-loading-text="数据加载中"
            element-loading-spinner="el-icon-loading"
          >
            <el-table
              :data="tabledatas"
              border
              stripe
              ref="talbes"
              max-height="480px"
              @row-dblclick="rowdbclick"
              :header-cell-style="{
                background: '#cfcfcf',
                color: '#000000',
                'text-align': 'center',
              }"
              :cell-style="{ 'text-align': 'center' }"
              style="width: 100%"
              size="small"
              @selection-change="selectionChange"
              @row-click="handleRowClick"
            >
              <el-table-column
                type="selection"
                header-align="center"
                width="60"
              ></el-table-column>
              <el-table-column prop="control_action" label="联动动作"> </el-table-column>
              <el-table-column prop="active_status" label="启用状态">
                <template #default="scope">
                  <span v-if="scope.row.active_status == '1'">启用</span>
                  <span v-if="scope.row.active_status == '0'">禁用</span>
                </template>
              </el-table-column>
              <el-table-column prop="active_times" label="启用频率">
                <template #default="scope">
                  <span v-if="scope.row.active_times == '0'">单次</span>
                  <span v-if="scope.row.active_times == '1'">持续调用</span>
                </template>
              </el-table-column>
              <el-table-column prop="interval_unit" label="时间单位">
                <template #default="scope">
                  <span v-if="scope.row.interval_unit == '0'">分</span>
                  <span v-if="scope.row.interval_unit == '1'">时</span>
                  <span v-if="scope.row.interval_unit == '2'">天</span>
                  <span v-if="scope.row.interval_unit == '3'">月</span>
                  <span v-if="scope.row.interval_unit == '4'">年</span>
                </template>
              </el-table-column>
              <el-table-column
                prop="start_date"
                label="开始时段"
                width="120"
                :formatter="dateFormat"
              >
              </el-table-column>
              <el-table-column
                prop="end_date"
                label="结束时段"
                width="120"
                :formatter="dateFormat"
              >
              </el-table-column>
              <el-table-column prop="interval_time" label="间隔时间"> </el-table-column>
              <el-table-column prop="interface_api" label="对应接口动作">
              </el-table-column>
              <el-table-column fixed="right" label="操作" width="120">
                <template slot-scope="scope">
                  <el-button
                    @click="editClick(scope.row)"
                    type="text"
                    icon="el-icon-edit"
                    style="color: #18bc9c; margin: 5px; padding: 0px"
                    >编辑</el-button
                  >
                </template>
              </el-table-column>
            </el-table>

            <div class="pagebox">
              <el-pagination
                @size-change="sizeChange"
                @current-change="currentChange"
                :current-page="param.pageNo"
                :page-sizes="[10, 30, 50, 100, 500]"
                :page-size="param.limit"
                layout="total, sizes, prev, pager, next, jumper"
                :total="dataTotal"
              >
              </el-pagination>
            </div>
          </div>
          <div>
            <el-dialog
              :title="dialogtitle"
              v-if="dialogVisible"
              v-dialogDrag
              :visible.sync="dialogVisible"
              width="70%"
              top="30px"
              :class="dialogVisible == true ? 'action01' : 'action02'"
              :before-close="handleClose"
            >
              <el-form
                :model="fromData.datas[0]"
                :inline="true"
                :rules="rules"
                ref="fromData"
              >
                <el-form-item
                  label="联动动作"
                  :label-width="formLabelWidth"
                  prop="control_action"
                >
                  <el-input
                    v-model="fromData.datas[0].control_action"
                    autocomplete="off"
                    placeholder="联动动作"
                    style="width: 215px"
                  ></el-input>
                </el-form-item>
                <el-form-item
                  label="启用状态"
                  :label-width="formLabelWidth"
                  v-if="fromData.datas[0].control_action_id != ''"
                >
                  <el-select
                    v-model="fromData.datas[0].active_status"
                    disabled
                    style="width: 215px"
                    placeholder="请选择启用状态"
                  >
                    <el-option label="启用" value="1"></el-option>
                    <el-option label="禁用" value="0"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item
                  label="启用状态"
                  :label-width="formLabelWidth"
                  v-else
                  prop="active_status"
                >
                  <el-select
                    v-model="fromData.datas[0].active_status"
                    style="width: 215px"
                    placeholder="请选择启用状态"
                  >
                    <el-option label="启用" value="1"></el-option>
                    <el-option label="禁用" value="0"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item
                  label="启用频率"
                  :label-width="formLabelWidth"
                  prop="active_times"
                >
                  <!-- <el-input v-model="fromData.datas[0].active_times" autocomplete="off"></el-input> -->
                  <el-select
                    v-model="fromData.datas[0].active_times"
                    style="width: 215px"
                    placeholder="请选择启用频率"
                  >
                    <el-option label="单次" value="0"></el-option>
                    <el-option label="持续调用" value="1"></el-option>
                  </el-select>
                </el-form-item>
                <!-- <el-form-item label="启用时间段" :label-width="formLabelWidth" prop="active_period">
                  <el-input v-model="fromData.datas[0].active_period" autocomplete="off" placeholder="启用时间段"
                    style="width:215px;"></el-input>
                </el-form-item> -->
                <el-form-item
                  label="间隔时间"
                  v-if="fromData.datas[0].active_times == '1'"
                  :label-width="formLabelWidth"
                  key="interval_time"
                  prop="interval_time"
                >
                  <el-select
                    style="width: 215px"
                    v-model.number="fromData.datas[0].interval_time"
                    allow-create
                    default-first-option
                    clearable
                    @blur="nameblur($event)"
                    ref="nameSel"
                    filterable
                    placeholder="间隔时间"
                  >
                    <el-option label="半个小时" value="30"></el-option>
                    <el-option label="一个小时" value="60"></el-option>
                    <el-option label="一个半小时" value="90"></el-option>
                    <el-option label="两个小时" value="120"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item
                  label="间隔时间"
                  v-if="
                    fromData.datas[0].active_times == '0' ||
                    fromData.datas[0].active_times == ''
                  "
                  :label-width="formLabelWidth"
                >
                  <el-select
                    style="width: 215px"
                    v-model.number="fromData.datas[0].interval_time"
                    allow-create
                    default-first-option
                    @blur="nameblur($event)"
                    ref="nameSel"
                    disabled
                    filterable
                    remote
                    placeholder="间隔时间"
                  >
                    <el-option label="半个小时" value="半个小时"></el-option>
                    <el-option label="一个小时" value="一个小时"></el-option>
                    <el-option label="一个半小时" value="一个半小时"></el-option>
                    <el-option label="两个小时" value="两个小时"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item
                  label="开始时段"
                  :label-width="formLabelWidth"
                  prop="start_date"
                >
                  <el-time-select
                    placeholder="起始时间"
                    style="width: 215px"
                    v-model="fromData.datas[0].start_date"
                    :picker-options="{
                      start: '00:00',
                      step: '00:15',
                      end: '23:00',
                    }"
                  >
                  </el-time-select>
                </el-form-item>
                <el-form-item
                  label="结束时段"
                  :label-width="formLabelWidth"
                  prop="end_date"
                >
                  <el-time-select
                    placeholder="结束时段"
                    style="width: 215px"
                    v-model="fromData.datas[0].end_date"
                    :picker-options="{
                      start: '00:00',
                      step: '00:15',
                      end: '23:59',
                      minTime: fromData.datas[0].start_date,
                    }"
                  >
                  </el-time-select>
                </el-form-item>
                <el-form-item
                  label="时间单位"
                  v-if="
                    fromData.datas[0].active_times == '0' ||
                    fromData.datas[0].active_times == ''
                  "
                  :label-width="formLabelWidth"
                >
                  <el-input
                    v-model="fromData.datas[0].interval_unit"
                    autocomplete="off"
                    placeholder="时间单位"
                    style="width: 215px"
                    :disabled="true"
                  ></el-input>
                </el-form-item>
                <el-form-item
                  label="时间单位"
                  v-if="fromData.datas[0].active_times == '1'"
                  :label-width="formLabelWidth"
                  key="interval_unit"
                  prop="interval_unit"
                >
                  <!-- <el-input v-model="fromData.datas[0].interval_unit" autocomplete="off" placeholder="时间单位"
                    style="width:215px;"></el-input> -->
                  <el-select
                    v-model="fromData.datas[0].interval_unit"
                    style="width: 215px"
                    placeholder="时间单位"
                  >
                    <el-option label="分" value="0"></el-option>
                    <el-option label="时" value="1"></el-option>
                    <el-option label="天" value="2"></el-option>
                    <el-option label="月" value="3"></el-option>
                    <el-option label="年" value="4"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item
                  label="对应接口动作"
                  :label-width="formLabelWidth"
                  prop="interface_api"
                >
                  <el-input
                    v-model="fromData.datas[0].interface_api"
                    autocomplete="off"
                    placeholder="对应接口动作"
                    style="width: 215px"
                  ></el-input>
                </el-form-item>
              </el-form>
              <span slot="footer" class="dialog-footer">
                <el-button @click="handleClose">取 消</el-button>
                <el-button type="primary" @click="save">保 存</el-button>
              </span>
            </el-dialog>
          </div>
        </div>
      </el-main>
    </el-container>
  </div>
</template>

<script>
import SideHeader from "@/views/inc/SideHeader";
import Navlanmu from "@/views/inc/Navlanmu";
import LeftMenuMessage from "@/views/inc/LeftMenuMessage";
import { getDateTimes, numFormat, getDateWeek, downloadCallback } from "@/utils/index.js";
import { getlist, getexpro, getgridsave, getdeletes } from "@/api/message/list";
import moment from "moment";

export default {
  name: "Controlaction",
  components: { SideHeader, Navlanmu, LeftMenuMessage },
  data() {
    return {
      loading: false,
      loadingdata1: false,
      isloading: false,
      param: {
        funId: "msg_control_action",
        baseSQL: "",
        warnStatus: "",
        name: "",
        offset: 0,
        pageNo: 1,
        limit: 10,
      },
      dataTotal: 0,
      tabledatas: [],
      selectionChangeData: "",
      dialogtitle: "",
      dialogVisible: false,
      formLabelWidth: "130px",
      fromData: {
        funId: "msg_control_action",
        is_iot: false,
        datas: [
          {
            control_action: "", //联动动作
            active_status: "", //启用状态
            active_times: "", //启用频率
            interval_unit: "", //时间单位
            active_period: "", //启用时间段
            interval_time: "", //间隔时间
            interface_api: "", //对应接口动作
            start_date: "", //开始时段
            end_date: "", //结束时段
          },
        ],
      },
      rules: {
        control_action: [{ required: true, message: "联动动作必填", trigger: "blur" }],
        active_status: [{ required: true, message: "启用状态必填", trigger: "blur" }],
        active_times: [{ required: true, message: "启用频率必填", trigger: "blur" }],
        interval_unit: [{ required: true, message: "时间单位必填", trigger: "blur" }],
        active_period: [{ required: true, message: "启用时间段必填", trigger: "blur" }],
        interval_time: [
          { required: true, message: "间隔时间必填", trigger: "blur" },
          {
            required: true,
            type: "number",
            message: "只能填写数字",
            trigger: "blur",
          },
        ],
        interface_api: [{ required: true, message: "对应接口动作必填", trigger: "blur" }],
        start_date: [{ required: true, message: "开始时段必填", trigger: "blur" }],
        end_date: [{ required: true, message: "结束时段必填", trigger: "blur" }],
      },
      statusData: "",
    };
  },
  mounted() {
    //
    this.getDatas();
  },
  created() {
    this.isloading = false;
  },
  methods: {
    //判断表单是否变化
    handleClose() {
      let num = 0;
      for (const key in this.fromData.datas[0]) {
        if (this.fromData.datas[0][key] == "") {
          // num = num + 0
          num += 0;
        } else if (this.fromData.datas[0][key] == null) {
          // num = num + 0
          num += 0;
        } else {
          // num = num + 1
          num += 1;
        }
      }
      if (this.dialogtitle == "新增动作") {
        if (num != 0) {
          this.$confirm("表单未保存,是否关闭?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          })
            .then(() => {
              this.dialogVisible = false;
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "取消关闭",
              });
            });
        } else {
          this.dialogVisible = false;
        }
      } else {
        // console.log('222',JSON.stringify(this.fromData.datas[0]))
        // console.log('22222',sessionStorage.getItem("initForm"))
        if (
          JSON.stringify(this.fromData.datas[0]) == sessionStorage.getItem("initForm")
        ) {
          this.dialogVisible = false;
        } else {
          this.$confirm("表单未保存,是否关闭?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          })
            .then(() => {
              this.dialogVisible = false;
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "取消关闭",
              });
            });
        }
      }
      // console.log('num',num)
    },
    //禁用启用按钮
    forbiddenClick() {
      // this.loading = true
      let fromData = {
        funId: "msg_control_action",
        is_iot: false,
        datas: [{}],
      };
      let statusName = "";
      fromData.datas = this.selectionChangeData;
      // if (this.statusData == '0') {
      //   for (let i = 0; i < fromData.datas.length; i++) {
      //     fromData.datas[i].active_status = '1'
      //   }
      //   statusName = '禁用'
      // }
      // if (this.statusData == '1') {
      //   for (let i = 0; i < fromData.datas.length; i++) {
      //     fromData.datas[i].active_status = '0'
      //   }
      //   statusName = '启用'
      // }
      for (let i = 0; i < fromData.datas.length; i++) {
        if (fromData.datas[i].active_status != this.statusData) {
          this.$message({
            message: "只能选择相同状态记录，进行启用/禁用",
            type: "error",
          });
          this.getDatas();
          return false;
        } else if (this.statusData == "1") {
          fromData.datas[i].active_status = "0";
          statusName = "禁用";
        } else if (this.statusData == "0") {
          fromData.datas[i].active_status = "1";
          statusName = "启用";
        }
      }
      this.$confirm(
        `当前选择了${this.selectionChangeData.length}条数据, 是否${statusName}?`,
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          // for (let i = 0; i < fromData.datas.length; i++) {
          //   if (fromData.datas[i].active_status != this.statusData) {
          //     this.$message({
          //       message: '只能选择相同状态记录，进行启用/禁用',
          //       type: 'error'
          //     });
          //     this.getDatas()
          //     return false;
          //   } else if (this.statusData == '0') {
          //     fromData.datas[i].active_status = '1'
          //   } else if (this.statusData == '1') {
          //     fromData.datas[i].active_status = '0'
          //   }
          // }
          getgridsave(fromData).then((res) => {
            if (res.data.code == "200") {
              console.log(this.statusData);
              if (this.statusData === "1") {
                console.log(11111);
                this.$message({
                  message: "修改禁用状态成功",
                  type: "success",
                });
              } else {
                console.log(112222);
                this.$message({
                  message: "修改启用状态成功",
                  type: "success",
                });
              }

              this.loading = false;
              this.getDatas();
              this.toggleSelection(e);
            } else {
              this.$message({
                message: "修改启用状态失败",
                type: "error",
              });
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "warning",
            message: `已取消${statusName}`,
          });
          this.getDatas();
          this.loading = false;
        });
    },
    //自定义间隔时间的下拉选
    nameblur(e) {
      // this.fromData.datas[0].interval_time = Number(e.target.value)
      // this.fromData.datas[0].interval_time = e.target.placeholder
      if (e.target.value) {
        this.fromData.datas[0].interval_time = Number(e.target.value);
      }
      // this.fromData.datas[0].interval_time = this.$refs.nameSel.selectedLabel
    },
    // 复选框按钮
    selectionChange(e) {
      if (e.length == 0) {
        this.statusData = "";
        this.selectionChangeData = "";
      } else {
        this.statusData = e[0].active_status;
        this.selectionChangeData = e;
      }
    },
    toggleSelection(rows) {
      if (rows) {
        rows.forEach((row) => {
          this.$refs.talbes.toggleRowSelection(row, false);
        });
        this.selectionChangeData = "";
      } else {
        this.$refs.talbes.clearSelection();
      }
    },
    handleRowClick(e) {
      this.$refs.talbes.toggleRowSelection(e);
      const _selectData = this.$refs.talbes.selection;
      this.selectionChange(_selectData);
    },
    handleAdd() {
      let fromData = {
        exportFields: [],
        ids: [],
        funId: "msg_control_action",
      };
      //动态获取表头
      let fields = [];
      this.$refs.talbes.$children.forEach((item) => {
        if (item.label != undefined && item.prop != undefined) {
          fields.push({
            title: item.label,
            value: item.prop,
          });
        }
        fromData.exportFields = JSON.stringify(fields);
      });
      //获取主键ID
      if (this.selectionChangeData.length != 0) {
        this.selectionChangeData.forEach((item, index) => {
          if (index != 0) {
            fromData.ids += ";";
          }
          fromData.ids += item.control_action_id;
        });
      } else {
        this.tabledatas.forEach((item, index) => {
          if (index != 0) {
            fromData.ids += ";";
            // console.log('fromData.ids',fromData.ids)
          }
          fromData.ids += item.control_action_id;
        });
      }
      downloadCallback(fromData, this.selectionChangeData.length);
    },
    // 数据搜索按钮
    onSearch() {
      this.param.pageNo = 1;
      this.getDatas();
    },
    getDatas() {
      if (this.param.name == "") {
        this.param.baseSQL = "";
      } else {
        this.param.baseSQL = 'control_action like"%' + this.param.name + '%"';
      }
      getlist(this.param).then((res) => {
        if (res.status == "200") {
          let resdata = res.data;
          this.tabledatas = resdata.rows;
          this.dataTotal = resdata.total;
        }
      });
    },
    //添加按钮
    AddData() {
      if (this.$refs["fromData"]) {
        this.$refs["fromData"].resetFields();
      }
      this.dialogtitle = "新增动作";
      this.dialogVisible = true;
      this.fromData.datas[0].control_action = "";
      this.fromData.datas[0].control_action_id = "";
      this.fromData.datas[0].active_status = "";
      this.fromData.datas[0].active_times = "";
      this.fromData.datas[0].interval_unit = "";
      this.fromData.datas[0].active_period = "";
      this.fromData.datas[0].interval_time = "";
      this.fromData.datas[0].interface_api = "";
      this.fromData.datas[0].control_action = "";
      this.fromData.datas[0].start_date = "";
      this.fromData.datas[0].end_date = "";
    },
    //编辑按钮
    editClick(e) {
      this.getDatas();
      if (this.$refs["fromData"]) {
        this.$refs["fromData"].resetFields();
      }
      this.dialogtitle = "修改动作";
      this.dialogVisible = true;
      this.fromData.datas[0] = e;
      if (e.interval_time == "30") {
        this.fromData.datas[0].interval_time = 30;
      } else if (e.interval_time == "60") {
        this.fromData.datas[0].interval_time = 60;
      } else if (e.interval_time == "90") {
        this.fromData.datas[0].interval_time = 90;
      } else if (e.interval_time == "120") {
        this.fromData.datas[0].interval_time = 120;
      } else if (e.interval_time == "") {
        this.fromData.datas[0].interval_time = " ";
      } else {
        this.fromData.datas[0].interval_time = Number(e.interval_time);
      }
      this.fromData.datas[0].start_date = this.startdate(e.start_date);
      this.fromData.datas[0].end_date = this.enddate(e.end_date);
      sessionStorage.setItem("initForm", JSON.stringify(this.fromData.datas[0]));
    },
    //双击打开编辑页面
    rowdbclick(row) {
      this.getDatas();
      this.dialogtitle = "修改动作";
      this.dialogVisible = true;
      this.fromData.datas[0] = row;

      if (row.interval_time == "30") {
        this.fromData.datas[0].interval_time = 30;
      } else if (row.interval_time == "60") {
        this.fromData.datas[0].interval_time = 60;
      } else if (row.interval_time == "90") {
        this.fromData.datas[0].interval_time = 90;
      } else if (row.interval_time == "120") {
        this.fromData.datas[0].interval_time = 120;
      } else {
        this.fromData.datas[0].interval_time = Number(row.interval_time);
      }
      this.fromData.datas[0].start_date = this.startdate(row.start_date);
      this.fromData.datas[0].end_date = this.enddate(row.end_date);
      if (this.$refs["fromData"]) {
        this.$refs["fromData"].resetFields();
      }
      sessionStorage.setItem("initForm", JSON.stringify(this.fromData.datas[0]));
    },
    //保存按钮
    save() {
      this.$refs["fromData"].validate((valid) => {
        if (valid) {
          // console.log('valid',valid)
          if (this.fromData.datas[0].control_action_id) {
            this.updateaction();
            this.dialogVisible = false;
          } else {
            this.addaction();
            this.dialogVisible = false;
          }
        }
      });
    },
    //修改数据
    updateaction() {
      getgridsave(this.fromData).then((res) => {
        if (res.data.code == "200") {
          this.$message({
            message: "修改成功",
            type: "success",
          });
          this.getDatas();
        } else {
          this.$message({
            message: "修改失败",
            type: "error",
          });
        }
      });
    },
    //添加数据
    addaction() {
      getgridsave(this.fromData).then((res) => {
        if (res.data.code == "200") {
          this.$message({
            message: "添加成功",
            type: "success",
          });
          this.getDatas();
        } else {
          this.$message({
            message: "添加失败",
            type: "error",
          });
        }
      });
    },
    delClick(info) {
      var tablefromdata = {
        funId: "msg_control_action",
        ids: "",
      };
      this.selectionChangeData.forEach((item) => {
        tablefromdata.ids += item.control_action_id + ";";
      });
      this.$confirm(`已选择${this.selectionChangeData.length}条数据, 是否删除?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        getdeletes(tablefromdata).then((res) => {
          console.log("res", res);
          // if(res.status=='200'){
          if (res.data.code == "200") {
            this.$message({
              message: "删除成功",
              type: "success",
            });
            this.getDatas();
          } else {
            this.$message({
              message: "删除失败",
              type: "error",
            });
          }
          // }
          // else{
          //   this.$message({
          //       message: '删除告警失败',
          //       type: 'error'
          //   });
          //}
        });
      });
    },
    indexMethod(index) {
      return (this.param.pageNo - 1) * this.param.limit + index + 1;
    },
    sizeChange(val) {
      this.param.limit = val;
      this.getDatas();
    },
    currentChange(val) {
      this.param.pageNo = val;
      this.param.offset = (val - 1) * this.param.limit;
      this.getDatas();
    },
    startdate(date) {
      return moment(date).format("HH:mm:ss");
    },
    enddate(date) {
      return moment(date).format("HH:mm:ss");
    },
    dateFormat(row, column, cellValue, index) {
      var date = row[column.property];
      if (date == undefined) {
        return "";
      }
      return moment(date).format(" HH:mm:ss");
    },
  },
};
</script>
<style>
.el-select-dropdown {
  min-width: 200px !important;
}
.kanbao-bigbox .el-loading-spinner .el-loading-text {
  color: #666 !important;
}
</style>
<style scoped>
.el-main {
  padding: 0px !important;
}

.kanbao-bigbox {
  margin-top: 0px;
}
</style>
<style scoped>
.action01 {
  animation: zoomIn 0.5s;
  animation-iteration-count: 1;
}

.action02 {
  animation: zoomOut 0.5s;
  animation-iteration-count: 1;
}

.righttop-search-box {
  background: #f8f8f8;
  padding: 8px 20px 7px 20px;
  border-bottom: 1px solid #ececec;
  position: fixed;
  top: 0;
  width: calc(100% - 55px);
  z-index: 4;
}

.righttop-search-box .el-form-item {
  margin-bottom: 0px !important;
}

.container-box {
  padding: 10px;
  margin: 50px 0;
}

.pagebox {
  text-align: right;
  padding: 10px;
  position: fixed;
  bottom: 0;
  right: 0;
  width: 100%;
  background-color: #ececec;
  z-index: 4;
}
</style>
